# include <bits/stdc++.h>
using namespace std;
int main() {
    int ans, n, x;
    cin >> n >> x;
    for(int i = 1; i <= n; i++) {
        int tmp = i;
        while(tmp) {
            int t = tmp % 10;
            if(t == x) ans++;
            tmp /= 10;
        }
    }
    cout << ans;
}